import { useSelector, useDispatch } from 'react-redux';
import { AppDispatch, RootState } from '../..';
import { fetchUserById } from './pokemonSlice';

export const Pokemon = () => {
  const pokemon = useSelector((state: RootState) => state.pokemon);
  const dispatch = useDispatch<AppDispatch>();  

  return (
    <div>
      <button onClick={() => {
        dispatch(fetchUserById(123))
      }}>点击获取数据</button>
      <>
        <h3>{pokemon.species.name}</h3>
        <img src={pokemon.species.url} />
      </>
    </div>
  )
};